<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
    <head>
        <title>用户管理</title>
        <meta http-equiv="content-type" content="text/html;charset=utf-8">
        <link href="../../css/mine.css" type="text/css" rel="stylesheet">
        <script type="text/javascript" src="/js/jquery-1.8.3.min.js"></script>
        <script type="text/javascript">
            $(function(){


               $("#deptselect").change(function () {
                 var deptid=  $(this).val();
                 if (deptid == -1){
                    alert("请您选择部门!");
                 }
                 else {
                     $.ajax( {
                         url:"/resource/demo2/getallroles",
                         data:"deptid="+deptid,
                         type:"post",
                         dataType:"json",
                         success:function(rs){
                             $("#roleselect")[0].length=0;
                             for (var i = 0; i <rs.length ; i++) {
                                 $("#roleselect")[0].add(new Option(rs[i].rname,rs[i].roleid));

                             }
                         }
                     });
                 }
               }) ;
                $("#loginname").blur(function(){
                    var loginname= $(this).val();
                    if (loginname == null || loginname == ""){
                        alert("请输入用户名");
                    }
                    else{
                        $.ajax({
                            url:"/resource/demo2/findByLoginname",
                                data:"loginname="+loginname,
                                type:"post",
                                dataType:"json",
                                success:function(rs) {
                                    $("#loginname").next().html(rs.message);
                                    if (rs.message === "您输入的用户名已经存在"){
                                        $("#loginname").focus();
                                    }
                                }
                        });
                    }
                });

 /*               $("#add").click(function (check) {
                    var deptselect = $("#deptselect").val();
                    var roleselect = $("#roleselect").val();
                    alert("dept:"+deptselect+",role:"+roleselect);
                    if (deptselect == -1){
                        alert("请选择部门");
                    }
                    if (roleselect ==-1){
                        alert("请选择职位");
                    }
                    else {
                        $("#add").submit(function(e){
                            alert("Submitted");
                        });
                    }
                });*/
    /*            $("#add").submit(function(){
                   var deptselect = $("#deptselect").val();
                   var roleselect = $("#roleselect").val();
                   if (deptselect == null ){
                       alert("请选择部门");
                       return false;
                   }
                   if (roleselect == null ){
                       alert("请选择职位");
                       return  false;
                   }
                });*/
            });
        </script>

    </head>

    <body>

        <div class="div_head">
            <span>
                <span style="float:left">当前位置是：-》资源管理》用户管理</span>
                <span style="float:right;margin-right: 8px;font-weight: bold">
                    <a style="text-decoration: none" href="/resource/demo2/getemployees">【返回】</a>
                </span>
            </span>
        </div>
        <div></div>

        <div style="font-size: 13px;margin: 10px 5px">
            <form action="/resource/demo2/insertEmp" method="post" >
            <table border="1" width="100%" class="table_a">
                <tr>
                    <td width="120px;">用户编号<span style="color:red">*</span>：</td>
                    <td><input type="text" name="employeenum" value="" /></td>
                </tr>
                <tr>
                    <td>登录账号<span style="color:red">*</span>：</td>
                    <td>
                       <input type="text" name="loginname"  id="loginname" value="zhangsan" /><span></span>
                    </td>
                </tr>
               
                <tr>
                    <td>用户姓名<span style="color:red">*</span>：</td>
                    <td>
						<input type="text" name="username" value="张三" /></td>
                </tr>
                <tr>
                    <td>密码<span style="color:red">*</span>：</td>
                    <td>
						<input type="text"  name="loginpassword" value="......" />
					</td>
                </tr>

                <tr>
                    <td>所属部门<span style="color:red">*</span>：</td>
                    <td>

                        <select id="deptselect" name="deptid" >
                            <option value="-1">请选择部门</option>
                            <c:forEach var="dept"  items="${depts}">
                                <option  value="${dept.deptid}">${dept.deptname}</option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>

                <tr>
                    <td>所属职位<span style="color:red">*</span>：</td>
                    <td>
                        
						<select name="roleid" id="roleselect">
							<option value="-1">请选择职位</option>
						</select>
                    </td>
                </tr>


				<tr>
                    <td>身份证<span style="color:red">*</span>：</td>
                    <td>
                        <input type="text" name="idcaid" value="372902198708084567" />
                    </td>                
                </tr>

				<tr>
                    <td>联系电话<span style="color:red">*</span>：</td>
                    <td>
                        <input type="text" name="telphone" value="17718181920"/>
                    </td>                
                </tr>

				<tr>
                    <td>邮箱<span style="color:red">*</span>：</td>
                    <td>
                        <input type="text" name="email" value="AAA@163.com" />
                    </td>                
                </tr>

				<tr>
                    <td>联系地址：</td>
                    <td>
                        <input type="text" name="address" value="海淀区软件园孵化器" />
                    </td>                
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <input type="submit" value="增加" id="add">
						<input type="reset" value="清空">
                    </td>
                </tr>  
            </table>
            </form>
        </div>
    </body>
</html>